package xyz.lilei123;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.annotation.Repeat;
import org.springframework.test.context.junit4.SpringRunner;
import xyz.lilei123.entity.COrder;
import xyz.lilei123.repository.OrderRepository;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
import java.util.Random;

/**
 * @author jack
 * @version 1.0
 * @date 28/11/2021 21:20
 **/
@RunWith(SpringRunner.class)
@SpringBootTest(classes = Starter.class)
public class test {

    @Resource
    private OrderRepository repository;

    @Test
    @Repeat(100)
    public void testAdd(){
        COrder order = new COrder();
        Random random = new Random();
        int userId = random.nextInt(2)+1;
        Random companyRandom = new Random();
        int companyId = companyRandom.nextInt(2);
        order.setDel(false);
        order.setCompanyId(companyId);
        order.setPositionId(userId);
        order.setUserId(userId);
        order.setPublishUserId(userId);
        order.setResumeType(1);
        order.setStatus("AUTO");
        order.setCreateTime(new Date());
        order.setUpdateTime(new Date());
        repository.save(order);
    }

    @Test
    public void testFind(){
        List<COrder> list = repository.findAll();
        list.forEach(order-> System.out.println(order.getId()+" "+order.getStatus()+" "+order.getUserId()));
    }

}
